package com.zjh.jpa.repository;

import com.zjh.jpa.entity.Talk;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TalkPageSortRepository extends PagingAndSortingRepository<Talk,Long> {
    //进行自定jpql
    @Query("from Talk where id = :id")
    //名字不能定义和自带名字一样不然会报错冲突
    Talk findById2(@Param("id") Long id);

    @Query(value = "select * from talk",nativeQuery = true)
    List<Talk> findList();
    //进行原生sql查询

}
